package com.qingzhou.web.controller.edc;

import com.mybatisflex.core.paginate.Page;
import com.qingzhou.common.enums.BusinessType;
import com.qingzhou.common.web.controller.BaseController;
import com.qingzhou.framework.annotation.QzLog;
import com.qingzhou.web.repository.entity.MaterialsEntity;
import com.qingzhou.web.service.MaterialsService;
import com.qingzhou.web.service.impl.params.request.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.noear.solon.annotation.*;
import org.noear.solon.core.handle.Result;

@Api("送检材料")
@Controller
@Mapping("edc/materials")
public class MaterialsController extends BaseController {

    @Inject
    MaterialsService materialsService;


    @ApiOperation("新增送检材料")
    @QzLog(title = "新增送检材料", businessType = BusinessType.INSERT)
    //@AuthPermissions("edc:materials:add")
    @Post
    @Mapping("add")
    public Result<Void> add(MaterialsAddForm form) {
        return toResult(materialsService.add(form));
    }

    @ApiOperation("删除送检材料")
    @QzLog(title = "删除送检材料", businessType = BusinessType.DELETE)
    //@AuthPermissions("edc:materials:delete")
    @Post
    @Mapping("delete")
    public Result<Void> delete(MaterialsDeleteForm form) {
        return toResult(materialsService.delete(form));
    }

    //@AuthPermissions("edc:materials:page")
    @Mapping("page")
    @ApiOperation("送检材料分页")
    public Page<MaterialsEntity> page(Page<MaterialsEntity> page, MaterialsEntity entity) {
        return materialsService.page(page,entity);
    }

    //@AuthPermissions("edc:materials:detail")
    @Get
    @Mapping("detail")
    @ApiOperation("送检材料详情")
    public MaterialsEntity detail(MaterialsDetailForm form) {
        return materialsService.detail(form);
    }

    @ApiOperation("编辑送检材料")
    @QzLog(title = "编辑送检材料", businessType = BusinessType.UPDATE)
    //@AuthPermissions("edc:materials:edit")
    @Post
    @Mapping("edit")
    public Result<Void> edit(MaterialsEditForm form) {
        return toResult(materialsService.edit(form));
    }
}
